<template>
	<view>
		<u-modal :show="modal_show" width="590rpx" :title="modal_title">
			<view class="modal_content" v-if="modal_content">{{modal_content}}</view>
			<slot name="content" v-if="!modal_content"></slot>
			<template slot="confirmButton">
				<view class="btn_list">
					<u-button class="cancel_btn" v-if="modal_showCancelButton"
						:text="modal_cancelText?modal_cancelText:'取消'" @click="cancel('cancel')"></u-button>
					<u-button class="confirm_btn" :style="modal_showCancelButton?'width:214rpx':''"
						:text="modal_confirmText?modal_confirmText:'确认'" @click="confirm('confirm')">
					</u-button>
				</view>
			</template>
		</u-modal>
	</view>
</template>
<script>
	import {
		mapMutations,
		mapGetters
	} from 'vuex'
	export default {
		name: "modal",
		computed: {
			...mapGetters(['modal_show', 'modal_title', 'modal_content', 'modal_showCancelButton', 'modal_confirmText',
				'modal_cancelText'
			])
		},
		data() {
			return {
				isSlot: false
			};
		},
		mounted() {
			// console.log(this.modal_title, this.modal_title)
		},
		methods: {
			cancel(res) {
				this.$store.commit('modal/hideModal')
				this.$store.commit('modal/success', res);
			},
			confirm(res) {
				this.$store.commit('modal/hideModal')
				this.$store.commit('modal/success', res);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btn_list {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.cancel_btn {
		border: 2rpx solid #8588AA;
		color: #C6C8DB;
		width: 214rpx;
	}

	.confirm_btn {
		border: 2rpx solid #333;
		background: #000000;
		color: #fff;
	}

	.cancel_btn,
	.confirm_btn {
		border-radius: 10rpx;
		font-size: 28rpx;
	}

	.modal_content {
		padding: 20rpx 0;
		font-size: 24rpx;
		color: #999999;
	}

	/deep/ .u-modal__content {
		padding: 24rpx 40rpx;
	}

	/deep/ .u-popup__content {
		background-color: transparent;
	}

	/deep/ .u-modal {
		background-color: #fff;
		border: none;
		border-radius: 20rpx;

		&__title {
			color: #333;
			font-size: 32rpx;
			font-weight: 400;
			padding-top: 40rpx;
		}
	}
</style>
